import django.contrib.admin as admin
from django.db.models import Q
from django.utils.translation import gettext_lazy as _


class IsCuteFilter(admin.SimpleListFilter):
    title = _('是否被引用')
    parameter_name = 'is_cute'

    def lookups(self, request, model_admin):
        return (
            (True, _('是')),
            (False, _('否')),
        )

    def queryset(self, request, queryset):
        print(self.value(), type(self.value()))
        if self.value() == 'True':
            return queryset.filter(nav__isnull=False)
        elif self.value() == 'False':
            return queryset.filter(nav__isnull=True)
        return queryset